package com.ghd.dataviz.utils;

import com.corundumstudio.socketio.SocketIOClient;
import com.ghd.dataviz.core.security.JwtTokenUtil;
import com.ghd.dataviz.core.security.impl.UserDetailsImpl;
import com.ghd.dataviz.core.utils.JsonUtil;

/**
 * @author ：ghd
 * @date ：Created in 2020-04-11 01:58
 * @description：
 * @modified By：
 * @version: $
 */
public class UserUtil {

    public static UserDetailsImpl getUserInfoByClient(SocketIOClient client) {
        String token = client.getHandshakeData().getSingleUrlParam("token");
        String json = JwtTokenUtil.getProperties(token);
        return JsonUtil.jsonToPojo(json, UserDetailsImpl.class);
    }
}
